<template>
	<view>
		<view class="wrap">
				<cu-custom bgColor="bg-gradual-blue" :isBack="true">
					<block slot="backText">返回</block>
					<block slot="content">待确认维保信息</block>
				</cu-custom>
				
				<!-- 头部开始 -->
				<view class="goods-header-wrap">
					<view class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : 1 == goodsNav}" @click="setNav(1)">
						<view v-if="count.task1>0" class="cu-tag badge">{{count.task1}}</view>待确认
					</view>
					<view class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : 2 == goodsNav}" @click="setNav(2)">
						已确认
					</view>
					<view class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : 0 == goodsNav}" @click="setNav(0)">
						无需确认
					</view>
				</view>
			
				<view v-for="(item, index) in dataList" class="goods-item-wrap" :class="item.isNowTask==1?'goods-item-wrap-now':''">
					<view class="goods-content-wrap">
						<view class="goods-name">
							<view class="goods-name-title">{{item.JobName}}</view>
						</view>
						<view class="goods-stock-wrap">
							<view class="goods-stock">维保人员</view>
							<view class="goods-stock">{{item.SignUserNames}}</view>
						</view>
						<view class="goods-stock-wrap">
							<view class="goods-stock">维保点位</view>
							<view class="goods-stock">{{item.QrcodeNames}}</view>
						</view>
						<view class="goods-stock-wrap">
							<view class="goods-stock">已维保 / 需维保</view>
							<view style="display: flex;">
								<view class="goods-stock-isok">{{item.SignCount}}</view>
								<view class="goods-stock-middle">/</view>
								<view class="goods-stock-notok">{{item.SignCount+item.NotSignCount}}</view>
							</view>
						</view>
						<view class="goods-stock-wrap">
							<view class="goods-stock">维保周期</view>
							<view class="goods-stock">{{item.TimeSlot}}</view>
						</view>
						<view class="goods-stock-wrap" style="border-bottom: 1px solid #F3F4F8;">
							<view class="goods-stock">维保时间</view>
							<view class="goods-stock-time">{{item.AddTime}}</view>
						</view>
						 <!-- 0 无需验收，1 待验收，2 通过，3 不通过 -->
						<view v-if="item.IsAccept==1" class="goods-price1">待确认</view>
						<view v-if="item.IsAccept==2" class="goods-price2">已确认</view>
						<view v-if="item.IsAccept==3" class="goods-price3">不通过</view>
						<view v-if="item.IsAccept==1&&item.MaintenanceConfirm==1" class="publish-goods-btn" @click="confirm(item.Id)">去确认</view>
						<view v-if="item.IsAccept==1&&item.MaintenanceConfirm==2" class="publish-goods-btn" @click="goScan(item.Id)">签字确认</view>
					</view>
				</view>
		</view>
	</view>
</template>

<script>
import request from '@/common/request.js';
import unifab from "@/components/beyondGod-drag/beyoundGod-drag.vue";	
export default {
	components: {
			unifab
		},
	data() {
		return {
			count:{
				task1:0,
			},
			themeColor: '#0079FE',
			authMessage:'',
			activeColor: '#0081ff',
			getData:{
				IsAccept:1,
			},
			dataList:[],
			current: 0,
			swiperCurrent: 0,
			tabsHeight: 0,
			dx: 0,
			goodsNav: 1,
			showDaiBan:0,
			showWorkOrder:0
		};
	},
	mounted() {
		console.log('mounted')
	},
	computed: {
	},
	onLoad() {
		let that=this
		that.getTaskList();
		//that.GetMyTaskListCount();
	},
	onShow(){
		let that=this
		uni.$on('update',function(data){
			if(data){
				console.log('update:true'+'onShow')
				that.getTaskList();
			}
		})
	},
	methods: {
		confirm(id){
			let that=this
			uni.showModal({
				title: '提示',
				content: '确认通过此维保吗？',
				success: function (res) {
					if (res.confirm) {
						uni.showLoading({
							title: '提交中...'
						})
						let opts = {
							url: 'SpareApi/SaveSignConfirm?sceneId='+id,
							method: 'post'
						};
						request.httpTokenRequest(opts).then(res => {
							uni.hideLoading();
							if(res.data.code == 1){
								that.getTaskList();
							}
							else{
								uni.showToast({ title: res.data.msg, icon: 'none' });
							}
						});
					}
				}
			});
		},
		setNav(goodsNav) {
			console.log('setNav')
			let that=this
			that.goodsNav=goodsNav
			that.getData.IsAccept = goodsNav
			that.getTaskList();
		},
		goScan(id){
			uni.navigateTo({
				url: '/pages-others/sign?id='+id+'&signType='+2
			})
		},
		getTaskList(){
			let that=this
			uni.showLoading({
				title: '加载中...'
			})
			let opts = {
				url: 'SpareApi/GetMyConfirmSignData',
				method: 'get'
			};
			request.httpTokenRequest(opts,that.getData).then(res => {
				uni.hideLoading();
				if(res.data.code == 1){
					that.dataList=[]
					that.dataList=res.data.data
				}
				else{
					uni.showToast({ title: res.data.msg, icon: 'none' });
				}
			});
		},
		GetMyTaskListCount(){
			let that=this
			uni.showLoading({
				title: '加载中...'
			})
			let opts = {
				url: 'SpareApi/GetMyTaskListCount',
				method: 'get'
			};
			request.httpTokenRequest(opts,that.getData).then(res => {
				uni.hideLoading();
				if(res.data.code == 1){
					that.count.task1=res.data.data.task1
				}
				else{
					uni.showToast({ title: res.data.msg, icon: 'none' });
				}
			});
		},
	}
};
</script>

<style lang="scss" scoped>
/* #ifndef H5 */
page {
	height: 100%;
	background-color: #f2f2f2;
}
/* #endif */
</style>

<style lang="scss" scoped>
	.cu-tag.badge{
		
			top:-10rpx !important;
			right:50rpx !important;
		
	}
	.goods-item-wrap-now{
		//border:2px solid #00B52A;
	}
	.goods-item-wrap {
		border-radius: 8rpx;
		background: #FFFFFF;
		display: flex;
		padding: 24rpx;
		margin: 12rpx;
		//width:100%;
		.goods-content-wrap{
			width: 100%;
		}
		.goods-name {
			width: 100%;
			font-size: 32rpx;
			font-weight: bold;
			display: flex;
			position: relative;
			border-bottom: 1px solid #F3F4F8;
			padding-bottom: 20rpx;
		}
		.goods-name-title{
			display: block;
			float: left;
		}
		.goods-name-type{
			display: block;
			float:right;
			color: #3B69FD;
			margin-right: 20rpx;
		}
		.goods-stock-wrap {
			display: flex;
			color: #969696;
			font-size: 24rpx;
			margin-top: 20rpx;
			justify-content: space-between;
		}
		
		.goods-stock {
			margin-right: 24rpx;
			font-size: 28rpx;
			color: #636571;
			line-height: 32rpx;
		}
		.goods-stock-isok{
			margin-right: 24rpx;
			font-size: 38rpx;
			color: #00B52A;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-middle{
			margin-right: 10rpx;
			font-size: 38rpx;
			color: #636571;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-notok{
			margin-right: 24rpx;
			font-size: 38rpx;
			color: #F53F3E;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-time {
			margin-right: 24rpx;
			font-size: 28rpx;
			color: #e7612e;
			padding-bottom: 20rpx;
		}
		.goods-shangxiaxian {
			font-size:24rpx;
			color: #3F71C4;
			margin-top: 14rpx;
		}
		
		.goods-price1 {
			font-size:26rpx;
			color: #3B69FD;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #D0D9F7;
			border-radius: 4rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
		.goods-price2 {
			font-size:26rpx;
			color: #15C9CA;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #C8ECEC;
			border-radius: 4rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
		.goods-price3 {
			font-size:26rpx;
			color: #FF1D1D;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #F6DFDF;
			border-radius: 4rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
		.goods-option-item {
			padding: 8rpx 16rpx;
			border-radius: 36rpx;
			font-size: 24rpx;
			margin-top: 24rpx;
		}
	}
	
.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}
.swiper-box {
	flex: 1;
}
.swiper-item {
	height: 100%;
}

	.goods-option-item {
		padding: 8rpx 16rpx;
		border-radius: 36rpx;
		font-size: 24rpx;
		margin-top: 24rpx;
	}

	.goods-option-item:not(:last-child) {
		margin-right: 24rpx;
	}

	.goods-option-item-action {
		background: #f1f0fe;
		color: #6991ce;
	}

	.goods-item-wrap {
		margin-top: 24rpx;
	}

	.goods-header-wrap {
		display: flex;
		align-items: center;
		padding: 24rpx;
		background: #FFFFFF;
		margin-bottom: 10rpx;
	}
	.goods-header-item{
		width:50%;
		text-align: center;
	}
	.goods-header-item-active{
		font-size: 30rpx;
		font-color: #333333;
		font-weight: bold;
		position: relative;
	}
	.goods-header-item-active::after{
		position: absolute;
		left: 50%;
		right: 0;
		background: #4372fe;
		height: 8rpx;
		content: "";
		bottom: -12rpx;
		width: 60rpx;
		margin-left: -30rpx;
		border-radius: 200rpx;
	}
	.goods-header-item-action {
		// font-size: 32rpx;
		// font-color: #333333;
		// font-weight: bold;
		position: relative;
	}

	.goods-header-item-action::after {
		// position: absolute;
		// left: 0;
		// right: 0;
		// background: #4372fe;
		// height: 8rpx;
		// content: "";
		// bottom: -12rpx;
	}
	.extraPosition{
		position: absolute;
		right: -5rpx;
		top: -10rpx;
		font-size: 20rpx;
		padding: 0rpx 10rpx;
		height: 28rpx;
		color: #ffffff;
		background-color: #dd514c;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}
	
	.publish-goods-btn {
		width:160rpx;
		background: #e7612e;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}
	
</style>

